﻿using ObjCore.Impl;
using ObjCore.Interface;
using ObjModelEditor.Edit;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace ObjModelEditor
{
    public partial class MainForm : Form
    {
        public MainForm()
        {
            InitializeComponent();
        }

        ILoader _l;
        IEditor _e;

        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            _l = new Loader();
            _e = new Editor(_l);

            _l.Open(@"G:\项目数据\00广深科技\GPS正确obj模型\GPS正确obj模型\jiancezhan.obj");
        }

        private void MIOpen_Click(object sender, EventArgs e)
        {
            using (var of = new OpenFileDialog())
            {
                of.Filter = ConstStrings.ObjFileFilter;

                var rt = of.ShowDialog();
                if (rt == DialogResult.OK)
                {
                    _l.Open(of.FileName);
                }
            }
        }

        private void MISaveAs_Click(object sender, EventArgs e)
        {
            using (var of = new SaveFileDialog())
            {
                of.Filter = ConstStrings.ObjFileFilter;
                var rt = of.ShowDialog();
                if (rt == DialogResult.OK)
                {
                    _l.SaveAs(of.FileName);
                }
            }
        }

        private void MICenterXYZmin_Click(object sender, EventArgs e)
        {
            _e.CenterZMin();
        }

        private void MICenterXYZ_Click(object sender, EventArgs e)
        {
            _e.Center();
        }

        private void SISize_Click(object sender, EventArgs e)
        {
            using (var form = new SizeForm())
            {
                var rt = form.ShowDialog();
                if (rt == DialogResult.OK)
                {
                    _e.SetSize(form.MSize);
                }
            }
        }

        private void MILeft_Click(object sender, EventArgs e)
        {
            _e.CenterXMin();
        }

        private void MIFront_Click(object sender, EventArgs e)
        {
            _e.CenterYMin();
        }
    }
}
